import Vue from 'vue'
import VueRouter from 'vue-router'
/**
 *  加载模块
 */
Vue.use(VueRouter)
/**
 *  路由配置
 */
const router = new VueRouter({
  base: __dirname,
  likActiveClass: 'link-active',
  routes: [
    {
      path: '/init',
      name: 'init',
      component: resolve => require(['../components/init.vue'], resolve),
      children: [
        {
          path: 'wallet',
          name: 'wallet',
          component: resolve => require(['../common/wallet/WalletIndex.vue'], resolve),
          meta: {title: '钱包'}
        },
        {
          path: '/index',
          name: 'PurchaseIndex',
          component: resolve => require(['../common/Purchase/PurchaseIndex.vue'], resolve),
          meta: {title: '能源宝'}
        },
      ]
    },
    {
      path: '/list',
      name: 'GoodsLinkItem',
      component: resolve => require(['../components/GoodsLinkItem.vue'], resolve),
      children: [
        {
          path: 'tire',
          name: 'TireList',
          component: resolve => require(['../common/GoodsList/TireList.vue'], resolve),
          meta: {title: '商品列表'}
        },
        {
          path: 'battery',
          name: 'BatteryList',
          component: resolve => require(['../common/GoodsList/BatteryList.vue'], resolve),
          meta: {title: '商品列表'}
        },
        {
          path: 'tool',
          name: 'ToolList',
          component: resolve => require(['../common/GoodsList/ToolList.vue'], resolve),
          meta: {title: '商品列表'}
        }
      ]
    },
    {
      path: '/code',
      name: 'code',
      component: resolve => require(['../components/Barcode.vue'], resolve)
    },
    {
      path: '/item',
      name: 'item',
      component: resolve => require(['../components/RedLinkItem.vue'], resolve),
      children: [
        {
          path: 'wallet/account',
          name: 'account',
          component: resolve => require(['../common/wallet/WalletAccount.vue'], resolve),
          meta: {title: '账单'}
        }
      ]
    },
    {
      path: '/gitem',
      name: 'gitem',
      component: resolve => require(['../components/GreenLinkItem.vue'], resolve),
      children: [
        {
          path: 'service/list',
          name: 'serviceList',
          component: resolve => require(['../common/CustomerService/ServiceList.vue'], resolve),
          meta: {title: '电池售后'}
        },
        {
          path: 'service/details/:id',
          name: 'serviceDetails',
          component: resolve => require(['../common/CustomerService/ServiceDeatils.vue'], resolve),
          meta: {title: '售后'}
        },
        {
          path: 'service/apply',
          name: 'serviceApply',
          component: resolve => require(['../common/CustomerService/ServiceApply.vue'], resolve),
          meta: {title: '申请售后'}
        },
        {
          path: 'service/write',
          name: 'serviceWrite',
          component: resolve => require(['../common/CustomerService/ServiceWrite.vue'], resolve),
          meta: {title: '申请售后'}
        },
        {
          path: 'service/step/:id/:orderNum',
          name: 'serviceStep',
          component: resolve => require(['../common/CustomerService/ServiceStep.vue'], resolve),
          meta: {title: '售后进度'}
        },
        {
          path: 'complaint/index',
          name: 'complaintIndex',
          component: resolve => require(['../common/Complaint/ComplaintIndex.vue'], resolve),
          meta: {title: '投诉'}
        },
        {
          path: 'complaint/list',
          name: 'complaintList',
          component: resolve => require(['../common/Complaint/ComplaintList.vue'], resolve),
          meta: {title: '投诉订单'}
        },
        {
          path: 'complaint/time',
          name: 'complaintTime',
          component: resolve => require(['../common/Complaint/ComplaintTime.vue'], resolve),
          meta: {title: '查询历史订单'}
        },
        {
          path: '/receivables',
          name: 'ReceivablesIndex',
          component: resolve => require(['../common/Receivables/ReceivablesIndex.vue'], resolve),
          meta: {title: '收款'}
        },
        {
          path: '/receivables/code',
          name: 'ReceivablesCode',
          component: resolve => require(['../common/Receivables/ReceivablesCode.vue'], resolve),
          meta: {title: '收款'}
        }
      ]
    },
    {
      path: '/activity/seckill',
      name: 'Seckill',
      component: resolve => require(['../common/ActivityDetails/Seckill.vue'], resolve),
      meta: {title: '活动详情'}
    },
    {
      path: '/activity/group',
      name: 'Group',
      component: resolve => require(['../common/ActivityDetails/Group.vue'], resolve),
      meta: {title: '活动详情'}
    },
    {
      path: '/activity/full',
      name: 'Full',
      component: resolve => require(['../common/ActivityDetails/Full.vue'], resolve),
      meta: {title: '活动详情'}
    },
    {
      path: '/login',
      name: 'login',
      component: resolve => require(['../components/login.vue'], resolve),
      meta: {title: '登录'}
    },
  ],
  scrollBehavior (to, from, savedPosition) {
    return { x: 0, y: 0 }
  },
})

/**
 *  路由出口
 */
export default router
